package com.builder;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

import com.model.Familia;
import com.view.FamiliaView;

@SuppressWarnings("serial")
@ManagedBean
@ViewScoped
public class FamiliaBuilder extends BaseBuilder<FamiliaView, Familia> {

	public Familia toDomain(FamiliaView view) {
		return new Familia(view.getId(), view.getDescripcion(), view.getPadre()
				.getId() != null ? new Familia(view.getPadre().getId(), null,
				null) : null);
	}

	public FamiliaView toView(Familia model) {
		return new FamiliaView(model.getID(), model.getDescripcion(),
				model.getPadre() != null ? new FamiliaView(model.getPadre()
						.getID(), null, null) : new FamiliaView());
	}
}
